package com.cn.wanxi.servlet;

/**
 * servlet 页面控制层 只和页面打交道 jsp
 * service  服务逻辑层 供servlet调用  所有逻辑代码都写在服务层
 * model   只是一个实体层  用于依赖 用于数据的传输
 * dao  数据层  所有数据都来自于dao
 */

import com.cn.wanxi.model.TitleModel;
import com.cn.wanxi.service.CompanyService;
import com.cn.wanxi.service.TitleService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * 所有页面上的数据都应该从servlet层响应给前端
 */
//@WebServlet("/home")
public class CompanyServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        TitleService titleService = new TitleService();
        TitleModel titleModel = titleService.getTitleModel();
        req.setAttribute("titleModel", titleModel);
//        String name = companyService.getName();
//        req.setAttribute("newsTitle", name);
//        String producTitle=companyService.getproducTitle();
//        req.setAttribute("producTitle", producTitle);
        req.getRequestDispatcher("/jsp/home.jsp").forward(req, resp);//页面转发，转发数据
//        resp.sendRedirect("/jsp/home.jsp");//重定向   只是跳转页面
    }
}
